﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
using System.Data;
using System.Text;
namespace IHISCETeim.Web.MachineSys.PartsModel
{
    public partial class PartsDebtAddTuiHuo : PageBase
    {
        protected override string DWZRef
        {
            get
            {
                return "PartsDebtList";
            }
        }

        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.新增 };
            }
        }

        protected int DebtId
        {
            get {
                return GetRequestValue<int>("DebtId", 0);
            }
        }


        protected PartsDebtInfo _objAdd = null;
        protected PartsDebtInfo objAdd
        {
            get
            {
                if (_objAdd == null)
                    _objAdd = PartsDebtController.GetById(DebtId);
                return _objAdd;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "add")
            {
                addmenu();

            }
        }
        private void addmenu()
        {
            PartsDebtInfo obj = Request.SerializableObject<PartsDebtInfo>();         
            obj.State =-1;
            obj.OldDebtId = DebtId;
            obj.SalesAmount = 0 - obj.SalesAmount;
            obj.ORDRNum = "";
            obj.ODLNNum = "";

            int did = PartsDebtController.Add(obj);
            if (did > 0)
            {
                SuccessJson("退货/政策支持成功", this.DWZRef);
            }
            else
            {

                ErrorJson("退货/政策支持失败");
            }
        }
    }
}